<?php


namespace app\api\validate;


use think\Validate;
use app\common\model\Bank as BankModel;

class Bank extends Validate
{
    protected $rule = [
        'id|银行卡ID' => 'require|checkId',
        'holder|开户人' => 'require',
        'bank|开户行' => 'require',
        'subbranch|支行' => 'require',
        'account|开户账号' => 'require',
    ];

    protected $scene = [
        'add' => ['holder','bank','subbranch','account'],
        'edit' => ['id','holder','bank','subbranch','account'],
        'del' => ['id']
    ];

    public function checkId($value, $rule, $data)
    {
        if (!BankModel::find($value)) {
            return '银行卡不存在';
        }

        return true;
    }
}